package blackjack;

import java.awt.Dimension;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;

public class Juego extends javax.swing.JFrame {

    DefaultListModel listaCartasHum = new DefaultListModel();
    DefaultListModel listaBancaLogica = new DefaultListModel();
    Mazo mazo = new Mazo();
    JugadorHumano player = new JugadorHumano();
    Banca playerBanca = new Banca();
    boolean esperar = false;

    public Juego(JugadorHumano usuario) {
        initComponents();
        botonOK.setVisible(false);
        labelInfo.setText("Realizá tu apuesta");
        listaJugador.setModel(listaCartasHum);
        listaBanca.setModel(listaBancaLogica);

        player = usuario;
        System.out.println(player.getSaldo());
        labelSaldoActual.setText(Float.toString(player.getSaldo()));
        labelUsuario.setText(player.getNombre());

        //repartoInicial();

        Dimension d = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((d.width - this.getWidth()) / 2, (d.height - this.getHeight()) / 2);

    }

    public String sumarPuntos(DefaultListModel lista) {
        int contador = 0;

        for (int i = 0; i < lista.getSize(); i++) {
            Carta cart = (Carta) lista.get(i);
            contador = contador + cart.getValorEntero();
        }


        for (int i = 0; i < lista.getSize() && contador > 21; i++) {
            Carta cart = (Carta) lista.get(i);
            if (cart.getValor().compareTo("A") == 0) {
                contador = contador - 10;
            }
        }


        return Integer.toString(contador);
    }

    public void limpiarPantalla() {
        //txtApuesta.setText("");
        lableApostado1.setText("");
        listaCartasHum.clear();
        listaBancaLogica.clear();
        txtTotal1.setText("");
        txtTotal2.setText("");
        labelInfo.setText("Realiza tu apuesta");
    }

    public void esperar(int segundos) {
        try {
            Thread.sleep(segundos * 1000);
        } catch (InterruptedException ex) {
            Logger.getLogger(Juego.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void reiniciarPartida() {
        //actualizar DB
        limpiarPantalla();
        mazo = mazo.resetearMazo();
        botonApostar.setEnabled(true);
        botonPedirCarta.setEnabled(false);
        botonPlantarse.setEnabled(false);
        //repartoInicial();
    }

    private void repartoInicial() {

        Carta nuevaCarta = player.pedirCarta(mazo);
        listaCartasHum.addElement(nuevaCarta);
        txtTotal1.setText(sumarPuntos(listaCartasHum));
        
        nuevaCarta = player.pedirCarta(mazo);
        listaCartasHum.addElement(nuevaCarta);
        txtTotal1.setText(sumarPuntos(listaCartasHum));

        /*
         * Carta nuevaCarta = mazo.cartas.get(48);
         * listaCartasHum.addElement(nuevaCarta);
         * txtTotal1.setText(sumarPuntos(listaCartasHum));
         *
         * nuevaCarta = mazo.cartas.get(49);
         * listaCartasHum.addElement(nuevaCarta);
        txtTotal1.setText(sumarPuntos(listaCartasHum));
         */

        if (txtTotal1.getText().compareTo("21") == 0) {
            labelInfo.setText("BlackJack!!");
        }

        nuevaCarta = playerBanca.pedirCarta(mazo);
        listaBancaLogica.addElement(nuevaCarta);
        txtTotal2.setText(sumarPuntos(listaBancaLogica));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane = new javax.swing.JScrollPane();
        listaJugador = new javax.swing.JList();
        txtTotal1 = new javax.swing.JTextField();
        botonPlantarse = new javax.swing.JButton();
        labelTitulo = new javax.swing.JLabel();
        jPanel = new javax.swing.JPanel();
        txtApuesta = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        botonApostar = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        lableApostado1 = new javax.swing.JLabel();
        sarasa = new javax.swing.JLabel();
        labelSaldoActual = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        labelUsuario = new javax.swing.JLabel();
        labelCartasBanca = new javax.swing.JLabel();
        labelInfo = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        listaBanca = new javax.swing.JList();
        labelTotalJugHum = new javax.swing.JLabel();
        botonPedirCarta = new javax.swing.JButton();
        labelTotalBanca = new javax.swing.JLabel();
        labelCartasJugHum = new javax.swing.JLabel();
        txtTotal2 = new javax.swing.JTextField();
        botonOK = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        listaJugador.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Cartas Jugador" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane.setViewportView(listaJugador);

        botonPlantarse.setText("Plantarse");
        botonPlantarse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonPlantarseActionPerformed(evt);
            }
        });

        labelTitulo.setFont(new java.awt.Font("Tahoma", 0, 18));
        labelTitulo.setText("BlackJack Java");

        jPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        txtApuesta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtApuestaActionPerformed(evt);
            }
        });

        jLabel10.setText("Apuesta:");

        botonApostar.setText("Apostar");
        botonApostar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonApostarActionPerformed(evt);
            }
        });

        jLabel11.setText("Apostado:");

        lableApostado1.setText("0");

        sarasa.setText("Saldo:");

        labelSaldoActual.setText("0");

        jLabel1.setText("Usuario:");

        labelUsuario.setText("usuario");

        javax.swing.GroupLayout jPanelLayout = new javax.swing.GroupLayout(jPanel);
        jPanel.setLayout(jPanelLayout);
        jPanelLayout.setHorizontalGroup(
            jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelLayout.createSequentialGroup()
                .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel10))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelLayout.createSequentialGroup()
                        .addContainerGap(85, Short.MAX_VALUE)
                        .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel11)
                            .addComponent(sarasa))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(lableApostado1)
                            .addComponent(labelSaldoActual)))
                    .addGroup(jPanelLayout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtApuesta, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
                            .addComponent(botonApostar, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)))
                    .addGroup(jPanelLayout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(labelUsuario)))
                .addContainerGap())
        );
        jPanelLayout.setVerticalGroup(
            jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel10)
                .addGap(18, 18, 18)
                .addComponent(txtApuesta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(47, 47, 47)
                .addComponent(botonApostar, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(labelUsuario))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(lableApostado1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelSaldoActual)
                    .addComponent(sarasa))
                .addContainerGap())
        );

        labelCartasBanca.setText("Cartas Banca");

        labelInfo.setFont(new java.awt.Font("Tahoma", 0, 18));
        labelInfo.setText("Aca aviso lo que va pasando");

        jScrollPane4.setViewportView(listaBanca);

        labelTotalJugHum.setText("Total:");

        botonPedirCarta.setText("Pedir Cartas");
        botonPedirCarta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonPedirCartaActionPerformed(evt);
            }
        });

        labelTotalBanca.setText("Total");

        labelCartasJugHum.setText("Tus Cartas");

        botonOK.setText("Repartir");
        botonOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonOKActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelInfo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(labelTotalJugHum)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtTotal1))
                            .addComponent(botonPedirCarta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(labelCartasJugHum, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE))
                        .addGap(47, 47, 47)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(labelCartasBanca, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(botonPlantarse, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                                    .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(labelTotalBanca, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtTotal2, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE))
                                    .addComponent(botonOK))
                                .addGap(40, 40, 40)))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(labelInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
                        .addComponent(botonOK, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(labelTitulo))
                .addGap(13, 13, 13)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(botonPedirCarta, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(botonPlantarse, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(19, 19, 19)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelCartasBanca)
                            .addComponent(labelCartasJugHum))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)
                                .addGap(28, 28, 28))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelTotalJugHum)
                            .addComponent(labelTotalBanca)
                            .addComponent(txtTotal1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTotal2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(25, 25, 25))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botonPlantarseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonPlantarseActionPerformed

        botonPedirCarta.setEnabled(false);
        String totalBanca, totalHumano;

        Carta nuevaCarta = playerBanca.pedirCarta(mazo);
        listaBancaLogica.addElement(nuevaCarta);
        totalBanca = sumarPuntos(listaBancaLogica);
        txtTotal2.setText(totalBanca);

        while (Integer.parseInt(totalBanca) < 16) {
            labelInfo.setText("La Banca pide otra carta");

            Carta otraCarta = playerBanca.pedirCarta(mazo);
            listaBancaLogica.addElement(otraCarta);
            totalBanca = sumarPuntos(listaBancaLogica);
            txtTotal2.setText(totalBanca);
        }
        if (Integer.parseInt(totalBanca) > 21) {
            labelInfo.setText("La Banca se paso. Ganaste!");
            botonPlantarse.setEnabled(false);
            float saldo = Float.parseFloat(labelSaldoActual.getText());
            float apuesta = Float.parseFloat(lableApostado1.getText());

            if ((listaCartasHum.getSize() == 2) && (Integer.parseInt(txtTotal1.getText()) == 21)) {
                saldo = saldo + apuesta * 2;
                saldo = saldo + apuesta / 2;
            } else {
                saldo = saldo + apuesta * 2;
            }
            labelSaldoActual.setText(Float.toString(saldo));
            actualizarSaldo(saldo);

        } else {
            labelInfo.setText("La banca se planta");

            totalHumano = txtTotal1.getText();
            if (Integer.parseInt(totalBanca) > Integer.parseInt(totalHumano)) {
                labelInfo.setText(labelInfo.getText() + " Perdiste!");
                botonPlantarse.setEnabled(false);
                float saldo = Float.parseFloat(labelSaldoActual.getText());
                actualizarSaldo(saldo);
            } else {
                if (Integer.parseInt(totalBanca) == Integer.parseInt(totalHumano)) {
                    labelInfo.setText(labelInfo.getText() + " Empate!");
                    botonPlantarse.setEnabled(false);
                    float saldo = Float.parseFloat(labelSaldoActual.getText());
                    float apuesta = Float.parseFloat(lableApostado1.getText());
                    saldo = saldo + apuesta;
                    labelSaldoActual.setText(Float.toString(saldo));
                } else {
                    labelInfo.setText(labelInfo.getText() + " Ganaste!!");
                    float saldo = Float.parseFloat(labelSaldoActual.getText());
                    float apuesta = Float.parseFloat(lableApostado1.getText());
                    saldo = saldo + apuesta * 2;
                    labelSaldoActual.setText(Float.toString(saldo));
                    actualizarSaldo(saldo);


                    botonPlantarse.setEnabled(false);
                }
            }

        }
        //JOptionPane.showMessageDialog(this, "Partida terminada", "BlackJack", JOptionPane.INFORMATION_MESSAGE);
        //actualizar DB
        botonOK.setVisible(true);
        //reiniciarPartida();

    }//GEN-LAST:event_botonPlantarseActionPerformed

    private void actualizarSaldo(float saldo) {
        player.setSaldo(saldo);
        AdminDeDatos.getInstance().actualizarBD(player);
    }

    private void botonPedirCartaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonPedirCartaActionPerformed
        Carta nuevaCarta = player.pedirCarta(mazo);
        listaCartasHum.addElement(nuevaCarta);
        txtTotal1.setText(sumarPuntos(listaCartasHum));

        if (Integer.parseInt(txtTotal1.getText()) > 21) { //PERDISTE
            AdminDeDatos.getInstance().actualizarBD(player);
            //JOptionPane.showMessageDialog(this, "Te pasaste!");
            labelInfo.setText("Te pasaste!!");

            float saldo = Float.parseFloat(labelSaldoActual.getText());
            actualizarSaldo(saldo);

            botonOK.setVisible(true);
            botonPlantarse.setEnabled(false);

            botonApostar.setEnabled(false);
            botonPedirCarta.setEnabled(false);
            //botonPlantarse.setEnabled(false);
        }
    }//GEN-LAST:event_botonPedirCartaActionPerformed

    private boolean puedeApostar() {
        boolean puede = true;
        float saldo = Float.parseFloat(labelSaldoActual.getText());
        //int apostadoHastaMomento = Integer.parseInt(lableApostado1.getText());
        float apuesta = Float.parseFloat(txtApuesta.getText());
        if ((saldo - apuesta) >= 0) {
            return puede;
        } else {
            puede = false;
            return puede;
        }
    }

    private void habilitoBotones() {
        botonApostar.setEnabled(false);
        botonPedirCarta.setEnabled(true);
        botonPlantarse.setEnabled(true);

    }

    private void botonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonOKActionPerformed
        reiniciarPartida();

        labelInfo.setText("Realizá tu apuesta");
        botonOK.setVisible(false);

        botonPlantarse.setEnabled(true);

}//GEN-LAST:event_botonOKActionPerformed

    private void txtApuestaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtApuestaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtApuestaActionPerformed

    private void botonApostarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonApostarActionPerformed
        try {
            if (this.puedeApostar()) {
                float saldo = Float.parseFloat(labelSaldoActual.getText());
                //int apostadoHastaMomento = Integer.parseInt(lableApostado1.getText());
                float apuesta = Float.parseFloat(txtApuesta.getText());
                botonPedirCarta.setEnabled(false);
                botonPlantarse.setEnabled(false);

                labelSaldoActual.setText(Float.toString(saldo - apuesta));
                lableApostado1.setText(Float.toString(apuesta));
                //txtApuesta.setText("");

                habilitoBotones();

                repartoInicial();
                //FALTA SUMAR PUNTOS

            } else {

                JOptionPane.showMessageDialog(null, "Quedaste sin plata vicioso", "Alerta", JOptionPane.YES_NO_OPTION);
            }
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "Sin apostar, no podes jugar", "Alerta", JOptionPane.YES_NO_OPTION);
        }
    }//GEN-LAST:event_botonApostarActionPerformed
    /**
     * @param args the command line arguments
     */
    /*
     * public static void main(String args[]) {
     * java.awt.EventQueue.invokeLater(new Runnable() {
     *
     * public void run() { new Juego().setVisible(true); } }); }
     */
    /*
     * private String sumarStrings(String s1,String s2){ //String nuevoTotal =
     * Integer.toString((Integer.parseInt(txtTotal1.getText())+Integer.parseInt(nuevaCarta.getValor())));
     * //txtTotal1.setText(nuevoTotal); return s1; }
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botonApostar;
    private javax.swing.JButton botonOK;
    private javax.swing.JButton botonPedirCarta;
    private javax.swing.JButton botonPlantarse;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JPanel jPanel;
    private javax.swing.JScrollPane jScrollPane;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JLabel labelCartasBanca;
    private javax.swing.JLabel labelCartasJugHum;
    private javax.swing.JLabel labelInfo;
    private javax.swing.JLabel labelSaldoActual;
    private javax.swing.JLabel labelTitulo;
    private javax.swing.JLabel labelTotalBanca;
    private javax.swing.JLabel labelTotalJugHum;
    private javax.swing.JLabel labelUsuario;
    private javax.swing.JLabel lableApostado1;
    private javax.swing.JList listaBanca;
    private javax.swing.JList listaJugador;
    private javax.swing.JLabel sarasa;
    private javax.swing.JTextField txtApuesta;
    private javax.swing.JTextField txtTotal1;
    private javax.swing.JTextField txtTotal2;
    // End of variables declaration//GEN-END:variables
}
